package com.xz.courseschedule.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xz.courseschedule.entity.Course;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface CourseMapper extends BaseMapper<Course> {

    @Select("SELECT " +
            "CASE " +
            "  WHEN course_attr = '01' THEN '理论课' " +
            "  WHEN course_attr = '02' THEN '实验课' " +
            "  WHEN course_attr = '03' THEN '实践课' " +
            "  WHEN course_attr = '04' THEN '体育课' " +
            "  ELSE '其他' " +
            "END as name, " +
            "COUNT(*) as value " +
            "FROM course " +
            "GROUP BY course_attr")
    List<Map<String, Object>> getCourseTypeDistribution();
}
